package station;

public class Truck extends Vehicle{
    private double weight;
    private int numbersOfAxles;

    public Truck() {
    }

    public Truck(int length, String plateNo, double weight, int numbersOfAxles) {
        super(length, plateNo);
        this.weight = weight;
        this.numbersOfAxles = numbersOfAxles;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public int getNumbersOfAxles() {
        return numbersOfAxles;
    }

    public void setNumbersOfAxles(int numbersOfAxles) {
        this.numbersOfAxles = numbersOfAxles;
    }

    @Override
    public void print() {
        super.print();
        System.out.println("最大允许总质量："+this.getWeight());
        System.out.println("车轴数："+this.getNumbersOfAxles());
    }

    @Override
    public double getRate() {
        double rate = 0;
        int length = super.getLength();
        double weight = this.getWeight();
        int numbersOfAxles = this.getNumbersOfAxles();
        switch (numbersOfAxles){
            case 2:
                if (length<6000 && weight<4500){
                    rate = 0.6;
                }else if(length>=6000 || weight>=4500) {
                    rate = 0.9;
                }
                break;
            case 3: rate = 1.02; break;
            case 4: rate = 1.315; break;
            case 5: rate = 1.428; break;
            case 6: rate = 1.428; break;
        }
        return rate;
    }
}
